{include file="common/header"/}
<div class="LM-container">
    <div class="LM-main">
        <div class="admin-main layui-anim layui-anim-upbit">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>{$title}</legend>
            </fieldset>
            <form class="layui-form layui-form-pane" lay-filter="form">
                <!-- <div class="layui-form-item">
                    <label class="layui-form-label">所属位置</label>
                    <div class="layui-input-inline">
                        <select name="pid" lay-verify="required">
                            <option value="0">默认顶级</option>
                            {volist name="ArticleCate" id="vo"}
                            <option value="{$vo.id}" {if !empty($info) && $info.pid==$vo.id} selected {/if} >{$vo.ltitle}</option>
                            {/volist}
                        </select>
                    </div>
                </div> -->

                <div class="layui-form-item">
                    <label class="layui-form-label">文章名</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" lay-verify="required" placeholder="{:lang('pleaseEnter')}标题" class="layui-input">
                    </div>

                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                        <textarea name="description" placeholder="{:lang('pleaseEnter')}描述" class="layui-textarea"></textarea>
                    </div>

                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">关键词</label>
                    <div class="layui-input-inline">
                        <input type="text" name="keywords"  placeholder="{:lang('pleaseEnter')}关键词" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        (多个关键词用空格隔开)
                    </div>
                </div>

<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">链接</label>-->
<!--                    <div class="layui-input-inline">-->
<!--                        <input type="text" name="link"  lay-verify="url" placeholder="{:lang('pleaseEnter')}链接"  class="layui-input">-->
<!--                    </div>-->
<!--                    <div class="layui-form-mid layui-word-aux">-->
<!--                        必须是https 或者http-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">缩略图</label>
                    <input type="hidden" name="thumb" id="avatar">
                    <div class="layui-input-inline">
                        <div class="layui-upload">
                            <button type="button" class="layui-btn layui-btn-primary" id="addBtn"><i class="icon icon-upload3"></i>点击上传</button>
                            <div class="layui-upload-list">
                                <img class="layui-upload-img" id="addPic">
                                <p id="notice"></p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">点击量</label>
                    <div class="layui-input-inline">
                        <input type="text" name="hit_count" lay-verify="number" placeholder="{:lang('pleaseEnter')}点击量" class="layui-input">
                    </div>

                </div>
                <!-- <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('email')}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="author_email" lay-verify="email" placeholder="{:lang('pleaseEnter')}邮箱" class="layui-input">
                    </div>

                </div> -->
                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('status')}</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="status" value="1" title="启用">
                        <input type="radio" name="status" value="0" title="禁用">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">内容</label>

                </div>
                <script id="container" name="content" type="text/plain"></script>

                <div class="layui-form-item">
                    <div class="layui-input-inline">
                        <input type="hidden" name="id"  >
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                        <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
                    </div>
                </div>
            </form>
        </div>

    </div>
</div>

{include file="common/footer"/}
{$ueditor|raw};


<script>
    layui.use(['form', 'layer','upload'], function () {
        var form = layui.form, layer = layui.layer,$= layui.jquery,upload = layui.upload;
        var info = '';

        info = {:json_encode($info)};
        form.val("form", info);
        if(info){
            $('#addPic').attr('src',info.thumb);
        }
        form.render();
        form.on('submit(submit)', function (data) {
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("", data.field, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                        location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        });
        //普通图片上传
        var uploadInt = upload.render({
            elem: '#addBtn'
            ,url: '{:url("uploads/uploads")}'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#addPic').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res){
                if(res.code>0){
                    $('#avatar').val(res.url);
                }else{
                    //如果上传失败
                    return layer.msg('上传失败');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var notice = $('#notice');
                notice.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                notice.find('.demo-reload').on('click', function(){
                    uploadInt.upload();
                });
            }
        });
    });
</script>